import React, { useEffect } from 'react';
import { DatePicker } from 'antd';
import moment from 'moment';

export default function Date({
  options,
  value,
  defaultValue,
  onHandleChange,
  onChange,
  format,
  placeholder,
  ...props
}) {
  const handleChange = (e) => {
    console.log(e);
    onChange(e);
    onHandleChange?.(e);
  };
  
  return (
    <DatePicker
      style={{ width: '100%' }}
      changeOnBlur
      placeholder={placeholder || "请选择时间"}
      onChange={
        (_, value) => handleChange(format === 'timeStamp' ? moment(value).unix()*1000 : value)
      }
      {...props}
    />
  )

}